package com.amado.jvm;

import org.openjdk.jol.info.ClassLayout;

/**
 *
 * 未使用9
 * com.amado.jvm.ObjectHead$Test2 object internals:
 *  OFFSET  SIZE   TYPE DESCRIPTION                               VALUE
 *       0     4        (object header)                           01 00 00 00 (00000001 00000000 00000000 00000000) (1)
 *       4     4        (object header)                           00 00 00 00 (00000000 00000000 00000000 00000000) (0)
 *       8     4        (object header)                           82 c1 00 f8 (10000010 11000001 00000000 11111000) (-134168190)
 *      12     4        (loss due to the next object alignment)
 * Instance size: 16 bytes
 * Space losses: 0 bytes internal + 4 bytes external = 4 bytes total
 *
 * @author wangyulong
 * @version 1.5.0
 * @date 2021/4/18 22:56
 */
public class ObjectHead {
    public static void main(String[] args) {
        Test test = new Test();
        Test2 test2 = new Test2();
        Test2[] arary = new Test2[10];
        System.out.println(ClassLayout.parseInstance(test).toPrintable());
        System.out.println(ClassLayout.parseInstance(test2).toPrintable());
        System.out.println(ClassLayout.parseInstance(arary).toPrintable());
    }
    static class Test{
        private String name="abcde123451111111111111111111111111111111111111111111111111111111111";
        private int phone=Integer.MAX_VALUE;
        private long longValue=Long.MAX_VALUE;
        private Short age=1;
        private byte byteValue=127;
    }
    static class Test2{
    }
}

